package com.wisezone.HomeWork.home01;

import java.io.File;
import java.util.Scanner;

public class Test2 {
    public static void main(String[] args) {
        //创建输入对象
        Scanner scanner = new Scanner(System.in);
        //定义输入路径变量
        String path = null;

        //提示信息
        System.out.println("请输入——路径：");
        path = scanner.next();
        File file = new File(path);
        getPath(file);
    }

    /**
     *
     * @param path
     * @return
     */
    public static void  getPath(File srcFile) {
        String path = "";
        //判断路径是否存在
        if (srcFile.exists())
        {
            //判断是文件
            if (srcFile.isFile()){
                System.out.println("文件路径!"+srcFile.getAbsolutePath());
            }
            //判断是文件夹
            if (srcFile.isDirectory()){
                System.out.println("文件夹路径！"+srcFile.getAbsolutePath());
                if (srcFile.listFiles().length==0){
                    File f = null;
                    //循环
                    for (int i = 0; i<srcFile.listFiles().length;i++){
                        f=srcFile.listFiles()[1];
                        //递归调用自己
                        getPath(f);
                    }
                }
            }
        }else{
            System.out.println("不存在该路径");
        }

    }
}
